package client.controlpanel;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import source.DataSource;

/**
 * Starts data gathering, deactivates the button, activates the stop button
 * @author Michal
 *
 */
public class StartGatheringButton implements ActionListener {
	JButton stopButton;
	
	public StartGatheringButton(JButton stopButton) {
		this.stopButton = stopButton;
	}
	
	@Override
	public void actionPerformed(ActionEvent buttonEvent) {
		JButton button =  (JButton) buttonEvent.getSource();
		button.setEnabled(false);
		stopButton.setEnabled(true);
		
		DataSource activeDataSource = Configuration.getInstance().getActiveDataSource();
		activeDataSource.stopGatheringData(); //Just to be sure
		activeDataSource.startGatheringData();
	}

}
